
/*
$(document).ready(function() {
    var courseNameBefore = getUrlParms("courseNameBefore");
    console.log(courseNameBefore);
    $.ajax({
        url: "http://localhost:8080/course/queryAcourse",
        type: "GET",
        async: true,
        data: "courseNameBefore=" + courseNameBefore,
        dataType: "json",
        success: function (data) {
            console.log(data)
            var notice=data.data.noticeTeacher;
            $("input[name='noticeTitle']").val(notice.noticeTitle);
            //$("#select2 option:selected").val(notice.noticeAuthor);
            $("#select2 option[value='"+notice.noticeAuthor+"']").attr("selected","selected");
            tinyMCE.activeEditor.setContent(notice.noticeContent);
        }
    });

});
*/

//获取地址栏参数//可以是中文参数
function getUrlParam(key) {
    // 获取参数
    var url = window.location.search;
    // 正则筛选地址栏
    var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
    // 匹配目标参数
    var result = url.substr(1).match(reg);
    //返回参数值
    return result ? decodeURIComponent(result[2]) : null;
}

$(document).on('click', '#updata-btn', function() {
    var $courseNameBefore = getUrlParam("courseNameBefore");
    var $courseName=$("input[name='courseName']").val();
    var $courseNum=$("input[name='courseNum']").val();
    var $academyName=$("input[name='academyName']").val();
    var $courseCredihour=$("input[name='courseCredihour']").val();
    var $coursePeriod=$("input[name='coursePeriod']").val();
    var $courseType=$("input[name='courseType']").val();
    $.ajax({
        url: "http://localhost:8080/course/updataCourse",
        type: "GET",
        async: false,
        data:"courseNameBefore="+$courseNameBefore+"&courseName="+$courseName+"&courseNum="+$courseNum+"&academyName="+$academyName+"&courseCredihour="+$courseCredihour+"&coursePeriod="+$coursePeriod+"&courseType="+$courseType,
        dataType: "json",
        contentType:"application/json",
        success:function () {
            layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            setTimeout(function () {
                layer.msg('更新成功')
            },1500);

            var index = parent.layer.getFrameIndex(window.name);
            setTimeout(function(){
                parent.layer.close(index)
            }, 2000);
            parent.location.reload()
        },
        error:function () {
            alert("你的网络太慢了！更新失败!再试一次吧！");
        }
    });
});


